package com.yc.exception;

/**
 * 测评相关异常
 */
public class TestException extends RuntimeException {
    
    private String code;
    
    public TestException(String message) {
        super(message);
        this.code = "TEST_ERROR";
    }
    
    public TestException(String code, String message) {
        super(message);
        this.code = code;
    }
    
    public TestException(String message, Throwable cause) {
        super(message, cause);
        this.code = "TEST_ERROR";
    }
    
    public TestException(String code, String message, Throwable cause) {
        super(message, cause);
        this.code = code;
    }
    
    public String getCode() {
        return code;
    }
    
    // 常用的异常类型
    public static class TestNotFoundException extends TestException {
        public TestNotFoundException(String message) {
            super("TEST_NOT_FOUND", message);
        }
    }
    
    public static class TestNotStartedException extends TestException {
        public TestNotStartedException(String message) {
            super("TEST_NOT_STARTED", message);
        }
    }
    
    public static class TestAlreadyCompletedException extends TestException {
        public TestAlreadyCompletedException(String message) {
            super("TEST_ALREADY_COMPLETED", message);
        }
    }
    
    public static class TestTimeoutException extends TestException {
        public TestTimeoutException(String message) {
            super("TEST_TIMEOUT", message);
        }
    }
    
    public static class InvalidAnswerException extends TestException {
        public InvalidAnswerException(String message) {
            super("INVALID_ANSWER", message);
        }
    }
    
    public static class UnauthorizedAccessException extends TestException {
        public UnauthorizedAccessException(String message) {
            super("UNAUTHORIZED_ACCESS", message);
        }
    }
} 